package nl.boektrust.btsoep.shared.model;

public enum ContributorRoleCode {
	UNDEFINED, AUTHOR, WITH, ILLUSTRATEDBY, EDITEDBY, ADAPTEDBY, TRANSLATEDBY, OTHER;
	
	public static String stringValue(ContributorRoleCode t) {
		String value = new String();
		switch (t) {
		case UNDEFINED: value = "Onbekend"; break;
		case AUTHOR: value = "Auteur"; break;
		case WITH: value = "Ghost writer"; break;
		case ILLUSTRATEDBY: value = "Illustrator"; break;
		case EDITEDBY: value = "Redactie"; break;
		case ADAPTEDBY: value = "Bewerkt"; break;
		case TRANSLATEDBY: value = "Vertaler"; break;
		case OTHER: value = "Overig"; break;
		}
		return value;
		
	}
	
	public static String stringValueForOnix(ContributorRoleCode t) {
		String value = new String();
		switch (t) {
		case UNDEFINED: value = "Z99"; break;
		case AUTHOR: value = "A01"; break;
		case WITH: value = "A02"; break;
		case ILLUSTRATEDBY: value = "A12"; break;
		case EDITEDBY: value = "B01"; break;
		case ADAPTEDBY: value = "B05"; break;
		case TRANSLATEDBY: value = "B06"; break;
		case OTHER: value = "Z99"; break;
		
		}
		return value;
		
	}

	
	public static ContributorRoleCode parseStringIntoContributorRoleCode(String s) {
		for (ContributorRoleCode c : ContributorRoleCode.values()) {
			if (ContributorRoleCode.stringValue(c).equals(s) == true) return c;
		}
		return UNDEFINED;
	}
	
	public static ContributorRoleCode parseOnixStringIntoContributorRoleCode(String s) {
		for (ContributorRoleCode c : ContributorRoleCode.values()) {
			if (ContributorRoleCode.stringValueForOnix(c).equals(s) == true) return c;
		}
		return UNDEFINED;
	}

}
